package com.xxkk.spring_boot_web;

import com.xxkk.spring_boot_web.utils.MySQLSyncUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Applicationx
 *
 * @author peiyu
 * @date 2023/10/24
 */
@SpringBootApplication
@MapperScan("com.xxkk.spring_boot_web.sql")
public class Application {
    public static void main(String[] args) {
        InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties");
        try {
            Properties props = new Properties();
            props.load(inputStream);
            String jdbcUrl = props.getProperty("spring.datasource.url");
            String username = props.getProperty("spring.datasource.username");
            String password = props.getProperty("spring.datasource.password");
            MySQLSyncUtil.update(jdbcUrl, username, password);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        SpringApplication.run(Application.class, args);
    }
}
